#字典类型dict：可变的、无序的，数据格式key-value 键值对格式
# dic={} #定义一个空字典
# print(dic)
# dic1=dict() #定义一个空字典
# print(type(dic1))
# print(dic1)
# 数字也可以作为key，但是不建议，一般key都是字符串
#key作为dict唯一标识符，不能重复,value值类型没有限制
# dic01={'name':'lg','sex':1,'age':18,'score':98.5,'state':False}
# print(dic01)
# dic02={1:'ok',2:'no'}
# print(dic02)
# dic03={'name':'lg','name':'lugg'}
# print(dic03)
# dic04={'names':{'h01','h02','h03'},'ages':(29,19,32),'lengths':[23.5,67.8,89.6],'objs':{'keys':'values'}}
# print(dic04)
# dic01={}
# print(dic01)
# list1=['a','b','c'] #fromkeys  list--->dict
# dic01=dic01.fromkeys(list1)#fromkeys 给字典进行初始化，默认value为none
# print(dic01)
#dict() 字典函数使用
# dic001=dict(a='123',b='456')# a、b 表示key，=后对应value
# print(dic001)
# dic002=dict([('name','lg'),('age',18)])#tuple--->dict
# print(dic002)
#通过zip()将两个list组合一起转换dict
keys=['name','sex','age']
values=['jim','男',20]
dic002=dict(zip(keys,values))
# print(dic002)
# print(dic002['sex'])#通过关键字key来获取对应value值
dic002['age']=30 #通过关键字key来修改对应value值
# print(dic002)
dic002['address']='西安市雁塔区'#如果key不存在，数据添加到字典中
print(dic002)
# del dic002['address'] #根据指定key进行删除
# #del dic002
# dic002.clear()#清空数据
# print(dic002)

#print(dic002['name1'])#ey不存在会出现错误keyerror
print(dic002.get('name1')) #获取数据，key不存在会返回none

# print(dic002.keys())#获取所有key
# print(dic002.values())#获取所有value
#print(dic002.items())
for k,v in dic002.items():
    print(f'{k}:{v}')
#1+2+3+...+100=5050
#print(list(range(1,101)))
# sum=0
# for i in range(1,101):
#     sum=sum+i
# print(sum)

# isopen=True
# i=0
# while isopen:
#     i=i+1
#     if i>=100:
#         isopen=False
#     print(i)

sss='2366666666666666'
print(sss.count('3'))
list=[1,2,3,4,5,6,2,3,2]
print(list.count(2))
tuple1=(1,2,3,4,5,6,2,3,2)
print(tuple1.count(2))
